<%--
  Created by IntelliJ IDEA.
  User: ThinkPad
  Date: 2017/9/7
  Time: 19:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<html>
<head>
    <title>Spitter</title>
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/style.css"/> ">
</head>
<body>
    <div class="spittleForm">
        <h1>Spit it out...</h1>
        <form method="post" name="spittleForm">
            <input type="hidden" name="latitude">
            <input type="hidden" name="longitude">
            <textarea name="message" cols="80" rows="5"></textarea>
            <input type="submit" value="Add" />
        </form>
    </div>
    <div class="listTile">
        <h1>Recent Spittles</h1>
        <ul class="spittleList">
            <c:forEach items="${spittleList}" var="spittle">
                <li id="spittle_<c:out value="spittle.id"/>">
                    <div class="spittleMessage">
                        <c:out value="${spittle.message}"/>
                    </div>
                    <div>
                        <span class="spittleTime"><c:out value="${spittle.time}"/></span>
                        <span class="spittleLocation">
                    (<c:out value="${spittle.latitude}"/>,
                    <c:out value="${spittle.longtitude}"/>)
                </span>
                    </div>
                </li>
            </c:forEach>
        </ul>
        <c:if test="${fn:length(spittleList) gt 20}">
            <hr />
            <s:url value="/spittles?count=${nextCount}" var="more_url" />
            <a href="${more_url}">Show more</a>
        </c:if>
    </div>
</body>
</html>
